package com.scsj.supermarket.view.activity.shopermodel;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.scsj.supermarket.R;
import com.scsj.supermarket.base.BindBankCardBase;
import com.scsj.supermarket.bean.BaseBean;
import com.scsj.supermarket.presenter.BindBankCardPresenter;
import com.scsj.supermarket.utils.DialogUtils;
import com.scsj.supermarket.utils.SkipUtils;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;

import es.dmoral.toasty.Toasty;

/**
 * 绑定银行卡的银行预留手机号码验证页面
 * 手机号码验证页面
 */
public class PhoneCodeVerificationActivity extends BaseActivity implements View.OnClickListener, BindBankCardBase.IView {

    private String type;
    /**
     * 将发送短信验证码到182****4689
     */
    private TextView mTopHintTv;
    /**
     * 获取验证码
     */
    private Button mSendCodeBtn;
    /**
     * 请输入验证码
     */
    private EditText mRegisterCodeEt;
    /**
     * 验证信息
     */
    private Button mVerifacationCodeBtn;
    private BindBankCardPresenter bindBankCardPresenter;


    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_phone_code_verification);
        //  ScreenAdapterTools.getInstance().loadView((ViewGroup)getWindow().getDecorView());
        //ScreenAdapterTools.getInstance().reset(this);//如果希望android7.0分屏也适配的话,加上这句
        initToolbar();
        initView();
        setToolbarTitle("手机短信验证");
        hasBack(true);
        bindBankCardPresenter = new BindBankCardPresenter(this);
    }

    @Override
    protected void initView() {
        Intent intent = getIntent();
        type = intent.getStringExtra("type");

        mTopHintTv = (TextView) findViewById(R.id.top_hint_tv);
        mSendCodeBtn = (Button) findViewById(R.id.send_code_btn);
        mRegisterCodeEt = (EditText) findViewById(R.id.register_code_et);
        mVerifacationCodeBtn = (Button) findViewById(R.id.verifacation_code_btn);
    }

    @Override
    protected void initListener() {
        mSendCodeBtn.setOnClickListener(this);
        mVerifacationCodeBtn.setOnClickListener(this);

    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.send_code_btn:
                switch (type) {
                    case "bank":
                        // TODO: 2018/7/5
//                        bindBankCardPresenter.deliverSendSmsData();
                        break;
                    case "pay":
                        break;
                    default:
                        break;
                }
                break;
            case R.id.verifacation_code_btn:
                switch (type) {
                    case "bank":
                        // TODO: 2018/7/5
//                        bindBankCardPresenter.deliverBindData();


                        break;


                    case "pay":
                        SkipUtils.toResetPaymentPwd(this);//重置
                        break;
                }
                break;
        }
    }

    @Override
    public void SendSmsSuccessMsg(String s, BaseBean addDABean) {

    }

    @Override
    public void BindSuccessMsg(String s, BaseBean deleteDABean) {
//添加银行卡弹窗
        DialogUtils.getInstance()
                .with(this)//上下文
                .setlayoutId(R.layout.add_bank_cark_layout)//布局文件
                .setlayoutPosition(Gravity.CENTER)//位置
                .setlayoutPading(222, 0, 222, 0)//与屏幕距离
                .show();
    }

    @Override
    public void showDAErrorMsg(String s) {
        Toasty.error(this, s).show();
    }
}
